package org.bim.view.drag.design.api.vo;

import lombok.Getter;
import lombok.Setter;

/**
 * @author pengxg
 * @date 2021/12/16 2:20 下午
 */
@Getter
@Setter
public class R<T> {
    private Integer code;
    private T data;
    private String msg;
    private Boolean success;

    public static <T> R<T> success(T data){
        R<T> r =new R<>();
        r.setSuccess(true);
        r.setData(data);
        r.setCode(0);
        r.setMsg("success");
        return r;
    }
    public static <T> R<T> fail(String msg){
        R<T> r =new R<>();
        r.setSuccess(false);
        r.setData(null);
        r.setCode(1000);
        r.setMsg("fail");
        return r;
    }
    public static <T> R<T> fail(String msg,Integer code){
        R<T> r =new R<>();
        r.setSuccess(false);
        r.setData(null);
        r.setCode(code==null?1000:code);
        r.setMsg(msg);
        return r;
    }
}
